<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <script src="../js/jquery-1.11.3.js"></script>
    <script src="../js/jquery-3.2.1.js"></script>
</head>
<body>
<div>
    <form id="reg_form">
        <h4>用户注册</h4>
        <div>用户名：<input type="text" name="username"></div>
        <div>密码：<input type="password" name="password"></div>
        <div>电话：<input type="text" name="phone"></div>
        <div>邮箱：<input type="email" name="email"></div>
        <div>
            <input id="btn_reg" type="button" value="注册">
        </div>
    </form>
</div>

<script type="text/javascript">
    $("#btn_reg").click(function () {
        var url = "../user/handle_reg.do";
        var data = $("#reg_form").serialize();
        console.log("提交的数据： " + data);
        $.ajax({
            "url":url,
            "data": data,
            "type":"GET",
            "dataType":"json",
            "success":function (json) {
                if (json.state == 200){
                    alert("注册成功！");
                }else {
                    alert(json.message);
                }
            }
        });
    });
</script>

</body>
</html>